package ga.wemanager {
	import flash.events.Event;
	import flash.events.EventDispatcher;
	
	public class WEManager extends EventDispatcher{
		
		public static const DEFAULT_INSTANCE:String = 'wemanager.default_instance';
		
		private static var _instances:Object = { };
		
		public var name:String;
		
		public function WEManager(pName:String) {
			name = pName;
		}
		
		public static function getInstance(instance:String = WEManager.DEFAULT_INSTANCE):WEManager {
			if (WEManager._instances[instance] == undefined) {
				WEManager._instances[instance] = new WEManager(instance);
			}
			
			return WEManager._instances[instance];
		}
		
		public static function dispatchEvent(e:Event, instance:String = WEManager.DEFAULT_INSTANCE):void {
			WEManager.getInstance(instance).dispatchEvent(e);
		}
		
		public static function addEventListener(type:String, callback:Function, instance:String = WEManager.DEFAULT_INSTANCE):void {
			WEManager.getInstance(instance).addEventListener(type, callback);
		}
		
		public static function removeEventListener(type:String, callback:Function, instance:String = WEManager.DEFAULT_INSTANCE):void {
			WEManager.getInstance(instance).removeEventListener(type, callback);
		}
	}
}